#include <iostream>
#include <vector>
#include <deque>
#include <list>

using std::cout;
using std::endl;
using std::vector;
using std::deque;
using std::list;

void test()
{
    //初始化
    //1、创建空对象
    /* vector<int> number; */
    //2、创建count个value
    /* vector<int> number(10, 3); */
    //3、迭代器范围
    /* int arr[10] = {1, 3, 5, 7, 9, 10, 8, 6, 4, 2}; */
    /* vector<int> number(arr, arr + 10);//左闭右开[,) */
    //4、拷贝构造函数与移动构造函数
    //5、大括号
    vector<int> number = {1, 3, 5, 9, 7, 2, 6, 8, 4, 10};
    
    //遍历操作
    //1、使用下标进行遍历
    for(size_t idx = 0; idx != number.size(); ++idx)
    {
        cout << number[idx] << "  ";
    }
    cout << endl;

    //2、迭代器：泛型指针
    vector<int>::iterator it;//没有初始化it
    for(it = number.begin(); it != number.end(); ++it)
    {
        cout << *it << "  ";
    }
    cout << endl;

    //3、迭代器(对迭代器进行初始化)
    vector<int>::iterator it2 = number.begin();//初始化it2
    for(; it2 != number.end(); ++it2)
    {
        cout << *it2 << "  ";
    }
    cout << endl;

    //4、for与auto,C++11
    for(auto &elem : number)
    {
        cout << elem << "  ";
    }
    cout << endl;
}

void test2()
{
    //初始化
    //1、创建空对象
    /* deque<int> number; */
    //2、创建count个value
    /* deque<int> number(10, 3); */
    //3、迭代器范围
    /* int arr[10] = {1, 3, 5, 7, 9, 10, 8, 6, 4, 2}; */
    /* deque<int> number(arr, arr + 10);//左闭右开[,) */
    //4、拷贝构造函数与移动构造函数
    //5、大括号
    deque<int> number = {1, 3, 5, 9, 7, 2, 6, 8, 4, 10};
    

    //遍历操作
    //1、使用下标进行遍历
    for(size_t idx = 0; idx != number.size(); ++idx)
    {
        cout << number[idx] << "  ";
    }
    cout << endl;

    //2、迭代器：泛型指针
    deque<int>::iterator it;//没有初始化it
    for(it = number.begin(); it != number.end(); ++it)
    {
        cout << *it << "  ";
    }
    cout << endl;

    //3、迭代器(对迭代器进行初始化)
    deque<int>::iterator it2 = number.begin();//初始化it2
    for(; it2 != number.end(); ++it2)
    {
        cout << *it2 << "  ";
    }
    cout << endl;

    //4、for与auto,C++11
    for(auto &elem : number)
    {
        cout << elem << "  ";
    }
    cout << endl;
}

void test3()
{
    //初始化
    //1、创建空对象
    /* list<int> number; */
    //2、创建count个value
    /* list<int> number(10, 4); */
    //3、迭代器范围
    /* int arr[10] = {1, 3, 5, 7, 9, 10, 8, 6, 4, 2}; */
    /* list<int> number(arr, arr + 10);//左闭右开[,) */
    //4、拷贝构造函数与移动构造函数
    //5、大括号
    list<int> number = {1, 3, 5, 9, 7, 2, 6, 8, 4, 10};
    

    //遍历操作
    //1、使用下标进行遍历
#if 0
    for(size_t idx = 0; idx != number.size(); ++idx)
    {
        cout << number[idx] << "  ";
    }
    cout << endl;
#endif

    //2、迭代器：泛型指针
    list<int>::iterator it;//没有初始化it
    for(it = number.begin(); it != number.end(); ++it)
    {
        cout << *it << "  ";
    }
    cout << endl;

    //3、迭代器(对迭代器进行初始化)
    list<int>::iterator it2 = number.begin();//初始化it2
    for(; it2 != number.end(); ++it2)
    {
        cout << *it2 << "  ";
    }
    cout << endl;

    //4、for与auto,C++11
    for(auto &elem : number)
    {
        cout << elem << "  ";
    }
    cout << endl;
}

int main(int argc, char **argv)
{
    test3();
    return 0;
}

